package com.wg.core.exception;

import cn.hutool.core.util.StrUtil;

/**
 * 自定义异常
 *
 * @author 少爷123
 */
public class CustomException extends RuntimeException {
    private final short errorCode;
    private final String errorMessage;
    private final String className;

    public CustomException(String className, short errorCode, String errorMessage) {
        super(StrUtil.format(errorMessage));
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
        this.className = className;
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return this;
    }

    public short getErrorCode() {
        return errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public String getLogMessage() {
        return className + ": " + errorMessage;
    }
}
